﻿-- ================================================
-- Remarks: 
-- ================================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'DasIdeen_SubscriptionMaster_Insert') 
    BEGIN
        DROP  PROCEDURE  DasIdeen_SubscriptionMaster_Insert
    END
GO

CREATE PROC [DasIdeen_SubscriptionMaster_Insert]
-- =============================================
-- Author:		<Sagar s.k>
-- Create date: <12/26/2014>
-- Description:	<DasIdeen_SubscriptionMaster_Insert>
-- =============================================
-- Add the parameters for the stored procedure here
	(
				
				@SubscribItemCode int,
				@SubscribItemDescription varchar(1000),
				@SubscribUserMailID varchar(150),
				@SubscrbDate datetime,
 
				@Sys_CreatedByID varchar(50)= NULL,
				@Sys_ModifiedByID varchar(50) = NULL,
				@Sys_DeleteType int = 0,
				@Sys_OrganizationID int = NULL,
				@Sys_InitialPrimaryKeys varchar(max)= NULL,
				@Sys_WorkstationName varchar(50)= NULL,
				
				@Sys_DateOfCreation datetime OUTPUT,
				@SubscribKey int OUTPUT
	)
AS 
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
    SET NOCOUNT OFF 
	
	IF @Sys_WorkstationName = 'Default'	
	BEGIN
		SET @Sys_WorkstationName = (SELECT @@SERVERNAME);
	END
	DECLARE @CurrentDataTime datetime;
	SET @CurrentDataTime = GETDATE();

    INSERT INTO [SubscriptionMaster]
            ( 
				
				[SubscribItemCode] ,
				[SubscribItemDescription] ,
				[SubscribUserMailID] ,
				[SubscrbDate] ,
				[Sys_DateOfCreation] ,
				[Sys_DateOfModification] ,
				[Sys_CreatedByID] ,
				[Sys_ModifiedByID] ,
				[Sys_DeleteType] ,
				[Sys_IsDeleted] ,
				[Sys_OrganizationID] ,
				[Sys_InitialPrimaryKeys] ,
				[Sys_WorkstationName]
            )
	VALUES
			(  
				
                @SubscribItemCode ,
                @SubscribItemDescription ,
				@SubscribUserMailID ,
				@SubscrbDate ,

                @CurrentDataTime ,
                @CurrentDataTime ,
                @Sys_CreatedByID ,
                @Sys_ModifiedByID ,
                @Sys_DeleteType ,
                0,
                @Sys_OrganizationID ,
                @Sys_InitialPrimaryKeys ,
                @Sys_WorkstationName
			);
	SET @SubscribKey = SCOPE_IDENTITY();
	SET @Sys_DateOfCreation = @CurrentDataTime;
END
GO